<%
  @merchant_info = terminal_merchant.merchant_info
%>
<div class="container" >
  <div class="row mbot30">
    <div class="col-lg-5 col-xs-12 col-centered" id="login_success">
      <div class="row span5 col-centered shop_title">
        <% if params[:controller] != 'wifi/merchants' && params[:controller] != 'home' %>
          <%= link_to fa_icon(["angle-left", "2x"]), wifi_merchant_path(mid: params[:mid], vtoken: params[:vtoken]) %>
        <% end %>
        <h4 class="text-center"><strong><%= @merchant_info.try(:name) %></strong></h4>
      </div>

      <div class="row span5 col-centered succ-info">
        <div class="success-Icon">
        </div>
        <div class="success-font">
          <p >已成功连接免费WiFi</p>
          <p >
            本次获得 <span id='countdown' class="time_counter"><%= humanize_second(@auth_token.try(:left_duration) || 14400) %></span> 的免费上网时长。
          </p>
          <p >
            当前有 <%= AuthToken.actived(terminal_merchant.id).count %> 人与您同时在线。
          </p>
        </div>
      </div>

      <div class="row span5 col-centered" id="show_products">
        <div class="col-lg-12 col-sm-12 col-xs-12">
          <div class="quote-info p-header">
            <a href=<%= "#{wifi_products_path}?mid=#{params[:mid]}&&vtoken=#{params[:vtoken]}" %>>
              <span>热门商品推荐</span>
              <%= fa_icon("angle-right 2x",class: "pull-right")%>
            </a>
          </div>
          <div class="products_hot">
            <ul class="product_list">
              <% @products.each do |product| %>
                <li style="margin-top: 0; margin-bottom: 0; padding-left: 0;">
                  <figure class="product">
                    <figcaption>
                    <div>
                      <span class="name" data-placement="top" title="true" data-toggle="tooltip" data-original-title="#{product.name}">
                        商品: <%= product.name %>
                      </span>
                      <span class="price"> 价格: ¥<%= product.price %></span>
                    </div>
                    </figcaption>
                    <div class="product_thumb">
                      <%= image_tag product.product_photo.url %>
                      <div class="product_mask">
                          <%= link_to '', wifi_product_path(product), target: "_blank", class: 'product_mask_backdrop' %>
                      </div>
                      <div class="hot_mask">
                        <%= image_tag "hot.png" %>
                      </div>
                    </div>
                  </figure>
                </li>
              <% end %>
            </ul>
          </div>
        </div>
      </div>

      <div class="row span5 col-centered" id="show_activities">
        <div class="col-lg-12 col-sm-12 col-xs-12">
          <div class="quote-info p-header">
            <a href=<%= "#{wifi_activities_path}?mid=#{params[:mid]}&&vtoken=#{params[:vtoken]}" %>>
              <span>热门活动</span>
              <%= fa_icon("angle-right 2x",class: "pull-right")%>
            </a>
          </div>
        <div class="row span5 col-centered wifi_sections">

          <% @activities.each do |activity| %>
            <section class="panel">
              <header class="panel-heading">
                <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#collapse<%= activity.id %>">
                  <% if activity.hot %>
                    <%= image_tag "hu_hot.png", class: "hot_img" %>
                  <% end %>
                  <h4><%= activity.title %></h4>
                  <span class="duration"><%= activity.started_at %> ~ <%= activity.end_at %></span>
                  <span class="pull-right detail">详细 <%= fa_icon "angle-double-down" %></span>
                </a>
              </header>
              <div id="collapse<%= activity.id %>" class="panel-collapse collapse">
                <div class="panel-body">
                  <% if activity.cover %>
                    <%= image_tag activity.cover.url(:small) %>
                  <% end %>
                  <%= activity.description %>
                </div>
              </div>
            </section>
          <% end %>
        </div>
        </div>
      </div>

      <%= link_to "搜周边", wifi_surroundings_path(mid: params[:mid], vtoken: params[:vtoken]), class: "btn btn-lg btn-primary col-sm-12 col-xs-12 col-md-12", id: "surrounding" %>

    </div>

  </div>
</div>

<%= javascript_tag do %>
  timeCountDown('countdown',<%= @auth_token.try(:left_duration) || 14400 %>)
<% end %>
